﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Entities;
using Business;
namespace Presentation
{
    public partial class frmTraCuuSach : DevComponents.DotNetBar.Office2007Form
    {
        public frmTraCuuSach()
        {
            InitializeComponent();
        }

        private void frmTraCuuSach_Load(object sender, EventArgs e)
        {
            List<SachDTO> listSach = SachService.GetSachList();
            List<TheLoaiDTO> listTheLoai = TheLoaiService.GetTheLoaiList();
            List<TacGiaDTO> listTacGia = TacGiaService.GetTacGiaList();

            AutoCompleteStringCollection sach = new AutoCompleteStringCollection();
            AutoCompleteStringCollection theLoai = new AutoCompleteStringCollection();
            AutoCompleteStringCollection tacGia = new AutoCompleteStringCollection();
            foreach (SachDTO s in listSach)
            {
                sach.Add(s.TenSach);
            }
            foreach (TacGiaDTO tg in listTacGia)
            {
                tacGia.Add(tg.TenTacGia);
            }
            foreach (TheLoaiDTO tl in listTheLoai)
            {
                theLoai.Add(tl.TenTheLoai);
            }
            txtTenSach.AutoCompleteCustomSource = sach;
            txtTheLoai.AutoCompleteCustomSource = theLoai;
            txtTacGia.AutoCompleteCustomSource = tacGia;

        }

        private void btnTraCuu_Click(object sender, EventArgs e)
        {
            dgvKetQua.DataSource = SachService.SearchByTenSach(txtTenSach.Text);
        }

       
    }
}
